#ifndef ENCODE_H
#define ENCODE_H
#include <vector>
#include <map>
#include "common.h"

float * readImg(int &dim1,int &dim2,std::string filename);
int **quantize(float **blk, int n[BLK_DIM][BLK_DIM], float qs);
int *scan(int **quantized_mat);
void writeBitSeq(std::vector<bool> &bitbuffer, std::vector<bool> &bitSeq);
int getCat(int value);
void writeAmp(int size, int value,std::vector<bool> &bitbuffer);
void huffmanDC(std::vector<bool> &bitbuffer,int delta_dc,std::map<int,std::vector<bool> > &codebook);
void huffmanAC(std::vector<bool> &bitbuffer,int *vec1D,std::map<std::pair<int,int>,std::vector<bool> > &codebook);
void load_codebook(std::map<int,std::vector<bool> > &dc_codebook,std::map<std::pair<int,int>,std::vector<bool> > &ac_codebook);
void write_jpg(std::string filename,std::vector<bool> &bitbuffer);
int encode(float qs,int &nbits);
#endif
